﻿using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Options;
using System;
using System.Collections.Generic;
using System.Text;

namespace BlogDemo.Application
{
    public class AppConfigurtaionService
    {
        private readonly IConfiguration _configuration;
        private readonly ApplicationConfiguration _appConfiguration;
        private readonly TokenConfiguration _tokentConfiguration;
        public ApplicationConfiguration ApplicationConfiguration
        {
            get
            {
                return _appConfiguration;
            }
        }
        public TokenConfiguration TokenConfiguration
        {
            get
            {
                return this._tokentConfiguration;
            }
        }
        public AppConfigurtaionService(IConfiguration configuration,
            IOptions<ApplicationConfiguration> appConfiguration, 
            IOptions<TokenConfiguration> tokenConfiguration)
        {
            this._configuration = configuration;

     
            //_configuration.Bind("JwtSetting", _tokentConfiguration);

            this._appConfiguration = appConfiguration.Value;
            this._tokentConfiguration = tokenConfiguration.Value;
        }

        public string GetConnectionString(string name = "DefaultConnection")
        {
            return _configuration.GetConnectionString(name);
        }
    }
}
